<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 10px !important;
}

.size {
	width: 600px;
	position: relative;
	left: 28%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>


	<title>Cadastro de Alternativa</title>
</h:head>

<h:body>

	<ui:decorate template="/templateBase.xhtml">

		<ui:define name="center">
			<p:growl id="growl" life="3000" autoUpdate="true" />
			<h:form prependId="true" id="formAlternativa">
				<br />
				<br />
				<br />
				<br />
				<p:panel header="Cadastro de Alternativa" styleClass="size"
					footer="SAIES - Sistema de Avaliação Institucional de Ensino Superior">
					<br />

					<h:panelGrid columns="3">
						<h:outputText value="ID" />
						<p:inputText disabled="true" size="5"
							value="#{alternativaBacking.questaoSelecionada.id}" />
						<p:commandButton oncomplete="dlgQuestao.show()"
							update=":formPesquisaQuestao:tblQuestao" icon="ui-icon-search" />
					</h:panelGrid>
					<br />
					<h:panelGrid columns="1">
						<h:outputText value="Questão." />
						<p:inputTextarea autoResize="true" maxlength="100" required="true"
							requiredMessage="Informe a questão!" cols="80" rows="5"
							disabled="true" title="Digite a questão a ser cadastrada"
							value="#{alternativaBacking.questaoSelecionada.descricao}" />
					</h:panelGrid>

					<h:panelGrid columns="1">
						<h:outputText value="Alternativa " />
						<p:selectOneMenu value="#{alternativaBacking.alt.tipo}">
							<f:selectItem itemDisabled="true" itemLabel="Selecione" />
							<f:selectItem itemLabel="A" itemValue="A" />
							<f:selectItem itemLabel="B" itemValue="B" />
							<f:selectItem itemLabel="C" itemValue="C" />
							<f:selectItem itemLabel="D" itemValue="D" />
							<f:selectItem itemLabel="E" itemValue="E" />
						</p:selectOneMenu>
						<h:outputText value="Descrição:" />
						<p:inputTextarea autoResize="true" maxlength="100" required="true"
							requiredMessage="Informe a alternativa!" cols="80" rows="5"
							title="Digite a alternativa a ser cadastrada"
							value="#{alternativaBacking.alt.descricao}" />
					</h:panelGrid>

					<br />

					<div align="center">
						<h:panelGrid columns="3">

							<p:commandButton value="Salvar"
								action="#{alternativaBacking.salvar}"
								oncomplete="dlgPergunta.show()" icon="ui-icon-disk" />
							<p:commandButton value="Excluir" />
							<p:commandButton value="Cancelar" />

						</h:panelGrid>
					</div>

				</p:panel>
			</h:form>

			<h:form id="formPesquisaQuestao">
				<p:dialog widgetVar="dlgQuestao" width="600" height="400"
					hideEffect="clip" showEffect="clip">
					<p:dataTable id="tblQuestao"
						value="#{alternativaBacking.listaQuestao}" var="q"
						emptyMessage="Não foi encontrada nenhuma questão no banco de dados!"
						rows="20">
						<p:column headerText="ID">
							<h:outputText value="#{q.id}" />
						</p:column>

						<p:column headerText="Descrição">
							<h:outputText value="#{q.descricao}" />
						</p:column>

						<p:column headerText="Público">
							<h:outputText value="#{q.tipo}" />
						</p:column>

						<p:column headerText="Área">
							<h:outputText value="#{q.areaConhecimentoQuestao}" />
						</p:column>

						<p:column headerText="Ações">
							<p:commandButton value="Selecionar"
								actionListener="#{alternativaBacking.selecionaQuestao(q)}"
								ajax="false" update=":formAlternativa" />
						</p:column>

					</p:dataTable>
				</p:dialog>
			</h:form>

			<h:form id="formPergunta">
				<p:dialog widgetVar="dlgPergunta" width="500" height="100" hideEffect="clip" showEffect="clip"
					header="?"
					footer="SAIES - Sistema de Avaliação Institucional do Ensino Superior">
					<br />
					<br />
					<div align="center">
						<h:outputText
							value="Deseja continuar cadastrando alternativa para a questão selecionada?" />
						<br /> <br />
						<h:panelGrid columns="2">
							<p:commandButton value="Sim"
								actionListener="#{alternativaBacking.limpaCampos}" ajax="false" />
							<p:commandButton value="Não"
								actionListener="#{alternativaBacking.reset}" ajax="false" />
						</h:panelGrid>
					</div>
				</p:dialog>
			</h:form>

		</ui:define>
	</ui:decorate>
</h:body>
</html>